
package com.yimixian.app.user;

import com.yimixian.app.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import java.util.List;

/**
 * Created by liuletao on 2015/8/18.
 */
public class UserInfoEditView extends LinearLayout {

    public static final int HEAD_INDEX = 0;
    public static final int NICK_INDEX = 1;
    public static final int SEX_INDEX = 2;
    public static final int AGE_INDEX = 3;
    public static final int CAREER_INDEX = 4;
    public static final int REGISTPHONE_INDEX = 5;
    public static final int REGISTTIME_INDEX = 6;

    public UserInfoEditView(Context context) {
        super(context);
        initView();
    }

    public UserInfoEditView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public UserInfoEditView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    private void initView() {
        setOrientation(VERTICAL);
        // setBackgroundColor();
    }

    public void setDate(List<UserInfoEditViewItem> list) {
        for (int i = 0; i < list.size(); i++) {
            LayoutParams params = new LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(
                            i == HEAD_INDEX ? R.dimen.user_info_edit_headH
                                    : R.dimen.settings_item_height));
            if (i == HEAD_INDEX || i == REGISTPHONE_INDEX) {
                params.setMargins(0,
                        getResources().getDimensionPixelSize(R.dimen.user_info_edit_top), 0, 0);
            }
            UserInfoEditViewItem viewChild = list.get(i);
            viewChild.setLayoutParams(params);
            addView(viewChild);
        }
    }

}
